home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWWindow / Sources / FWWinPro.cpp < prev   
Encoding:
Text File  |  1995-11-08  |  5.7 KB  |  209 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWWinPro.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifdef FW_PRECOMPILE_BY_LAYER
  11. #include "FWOS.hpp"
  12. #endif
  13.  
  14. #ifdef FW_PRECOMPILE_BY_SUBSYSTEM
  15. #include "FWWindow.hpp"
  16. #endif
  17.  
  18.  
  19. #ifndef FWWINPRO_H
  20. #include "FWWinPro.h"
  21. #endif
  22.  
  23. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR2
  24.  
  25. #ifndef FWBARRAY_H
  26. #include "FWBArray.h"
  27. #endif
  28.  
  29. #ifndef FWITEXT_H
  30. #include "FWIText.h"
  31. #endif
  32.  
  33. #ifndef FWWINDOW_H
  34. #include "FWWindow.h"
  35. #endif
  36.  
  37. #ifndef FWITEXT_H
  38. #include "FWIText.h"
  39. #endif
  40.  
  41. // ----- OpenDoc Utilities -----
  42.  
  43. #ifndef _STDTYPIO_
  44. #include "StdTypIO.h"
  45. #endif
  46.  
  47. #ifndef _STORUTIL_
  48. #include <StorUtil.h>
  49. #endif
  50.  
  51. // ----- OpenDoc Includes -----
  52.  
  53. #ifndef SOM_ODStorageUnit_xh
  54. #include <StorageU.xh>
  55. #endif
  56.  
  57. #ifndef SOM_ODDraft_xh
  58. #include <Draft.xh>
  59. #endif
  60.  
  61. #ifndef SOM_ODFrame_xh
  62. #include <Frame.xh>
  63. #endif
  64.  
  65. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  66. #include <StdTypes.xh>
  67. #endif
  68.  
  69. #ifndef SOM_Module_OpenDoc_StdProps_defined
  70. #include <StdProps.xh>
  71. #endif
  72.  
  73. //========================================================================================
  74. //    Runtime Info
  75. //========================================================================================
  76.  
  77. #if FW_LIB_EXPORT_PRAGMAS
  78. #pragma lib_export on
  79. #endif
  80.  
  81. #ifdef FW_BUILD_MAC
  82. #pragma segment fwwindow
  83. #endif
  84.  
  85. //========================================================================================
  86. //    class FW_CWindowProperties
  87. //========================================================================================
  88.  
  89. //----------------------------------------------------------------------------------------
  90. //    FW_CWindowProperties::FW_CWindowProperties
  91. //----------------------------------------------------------------------------------------
  92.  
  93. FW_CWindowProperties::FW_CWindowProperties(Environment* ev)
  94. {
  95.     PrivInitProperties(ev);
  96. }
  97.  
  98. //----------------------------------------------------------------------------------------
  99. //    FW_CWindowProperties::~FW_CWindowProperties
  100. //----------------------------------------------------------------------------------------
  101.  
  102. FW_CWindowProperties::~FW_CWindowProperties()
  103. {
  104.     if (fSourceFrame)
  105.         fSourceFrame->Release(somGetGlobalEnvironment());
  106. }
  107.  
  108. //----------------------------------------------------------------------------------------
  109. //    FW_CWindowProperties::PrivInitProperties
  110. //----------------------------------------------------------------------------------------
  111.  
  112. void FW_CWindowProperties::PrivInitProperties(Environment* ev)
  113. {
  114. #ifdef FW_BUILD_MAC
  115.     FW_CPoint interiorSize(
  116.         FW_IntToFixed(FW_QDGlobals.screenBits.bounds.right - 64), 
  117.         FW_IntToFixed(FW_QDGlobals.screenBits.bounds.bottom - LMGetMBarHeight() - 4 - 4 - 20));
  118.     FW_CPoint position(FW_IntToFixed(4), FW_IntToFixed(LMGetMBarHeight() + 4 + 19));
  119.     fBoundsRect.Set(position.x, position.y, position.x + interiorSize.x, position.y + interiorSize.y);
  120.  
  121.     fMacTitle[0] = 0;
  122.     fMacProcID = FW_CWindow::PrivMacStyleToProcId(ev, FW_kDocumentWindow);
  123.     fMacHasCloseBox = TRUE;
  124.     fMacRefCon = 0;
  125. #endif
  126.  
  127. #ifdef FW_BUILD_WIN
  128.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  129. #endif
  130.  
  131.     fWasVisible = TRUE;
  132.     fIsFloating = FALSE;
  133.     fIsRootWindow = TRUE;
  134.     fShouldShowLinks = FALSE;
  135.     fSourceFrame = NULL;
  136.     fIsResizable = TRUE;
  137. }
  138.  
  139. //----------------------------------------------------------------------------------------
  140. //    FW_CWindowProperties::ReadWindowProperties
  141. //----------------------------------------------------------------------------------------
  142.  
  143. FW_Boolean FW_CWindowProperties::ReadWindowProperties(Environment* ev, ODFrame* frame)
  144. {    
  145.     FW_Boolean result = FALSE;
  146.     
  147.     // ----- Initialize the property record -----
  148.     if (fSourceFrame)
  149.         fSourceFrame->Release(somGetGlobalEnvironment());
  150.     PrivInitProperties(ev);
  151.     
  152.     // ----- read -----
  153.     ODStorageUnit* frameSU = frame->GetStorageUnit(ev);
  154.     ODStorageUnit* windowPropsSU = kODNULL;
  155.  
  156.     ODID id = ODGetStrongSURefProp(ev, frameSU, kODPropWindowProperties, kODStrongStorageUnitRef);
  157.     if (id == 0)
  158.         return FALSE;
  159.     
  160. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  161.     windowPropsSU = frameSU->GetDraft(ev)->AcquireStorageUnit(ev,id);
  162. #else
  163.     windowPropsSU = frameSU->GetDraft(ev)->GetStorageUnit(ev,id);
  164. #endif
  165.  
  166.     if (windowPropsSU)
  167.     {
  168.         ODRect odRect;
  169.         ODGetRectProp(ev, windowPropsSU, kODPropWindowRect, kODRect, &odRect);
  170.         fBoundsRect = odRect;
  171.         
  172. #ifdef FW_BUILD_MAC
  173.         ODIText* iText = ODGetITextProp(ev, windowPropsSU, kODPropWindowTitle, kODMacIText, NULL);
  174.         if (iText)
  175.             GetITextPString(iText, fMacTitle);
  176.         ::DisposeIText(iText);
  177.  
  178.         fMacProcID = ODGetSShortProp(ev, windowPropsSU, kODPropWindowProcID, kODSShort);
  179.         fMacHasCloseBox = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowHasCloseBox, kODBoolean);
  180.         fMacRefCon = ODGetSLongProp(ev, windowPropsSU, kODPropWindowRefCon, kODSLong);
  181. #endif
  182.  
  183.         fIsResizable = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowIsResizable, kODBoolean);
  184.         fWasVisible = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowIsVisible, kODBoolean);
  185.         fShouldShowLinks = ODGetBooleanProp(ev, windowPropsSU, kODPropShouldShowLinks, kODBoolean);
  186.         
  187.         fIsFloating = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowIsFloating, kODBoolean);
  188.         fIsRootWindow = ODGetBooleanProp(ev, windowPropsSU, kODPropWindowIsRootWindow, kODBoolean);
  189.         
  190.         if (windowPropsSU->Exists(ev, kODPropSourceFrame, kODStrongStorageUnitRef, 0))
  191.         {
  192.             ODID id = ODGetStrongSURefProp(ev, windowPropsSU, kODPropSourceFrame, kODStrongStorageUnitRef);
  193. #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
  194.             fSourceFrame = windowPropsSU->GetDraft(ev)->AcquireFrame(ev, id);
  195. #else
  196.             fSourceFrame = windowPropsSU->GetDraft(ev)->GetFrame(ev, id);
  197. #endif
  198.         }
  199.  
  200.         windowPropsSU->Release(ev);
  201.         
  202.         result = TRUE;
  203.     }
  204.  
  205.     return result;
  206. }
  207.  
  208. #endif
  209.